﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability_Management.Domain;
using Traceability_Management.ErrorCode;
using Traceability_Management.Read.Api.Application.Command.Farmings_NextWay;
using Traceability_Management.Read.Api.Application.Command.SlaughtsWay_NextWay;

namespace Traceability_Management.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Farmings_NextAllController : ControllerBase
    {
        IMediator mediator;

        public Farmings_NextAllController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加方式
        /// </summary>
        /// <param name="Farmings_Next"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> AddNextWay(Farmings_Next Farmings_Next)
        {
            try
            {
                AddNextWayCommand AddNextWayCommand = new AddNextWayCommand()
                {
                    Farmings_Next = Farmings_Next
                };
                return await mediator.Send(AddNextWayCommand);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpGet]
        public async Task<ApiResult<Farmings_Next>> FirstNextWay([FromQuery] FirstNextWayCommand request)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        [HttpPost]
        public async Task<ApiResult<int>> UpdateNextWay(Farmings_Next Farmings_Next)
        {
            try
            {
                UpdateNextWayCommand UpdateNextWayCommand = new UpdateNextWayCommand()
                {
                    Farmings_Next = Farmings_Next
                };
                return await mediator.Send(UpdateNextWayCommand);
            }
            catch (Exception)
            {
                throw;
            }
        }

    }
}
